﻿using System.Collections;

namespace CSharpPro._1020;

public class Demo
{
    /*
    public void TestPrint()
    {
        int[] arr = new int[5];
        arr[0] = 1;
        arr[4] = 5;
        //Console.WriteLine(arr[6]);
        string[] arr2 = new string[5];
        arr2[0] = "1";
        arr2[4] = "5";
        //Console.WriteLine(arr2[6]);
        int[] arr3 = { 1, 2, 3, 4 };

        //二维数组
        int[,] arr4 = new int[2, 3];
        arr4[0, 0] = 1;
        arr4[1, 2] = 2;

        string[,] arr5 =
        {
            { "1", "2", "3" },
            { "4", "5", "6" }
        };

        int[] arr6 = { 12, 35, 7, 46 };
        Array.Sort(arr6); //升序
        Array.Reverse(arr6); //降序
        Console.WriteLine();
        foreach (int i in arr6)
        {
            Console.Write(i + "\t");
        }
        
        Student[] students = new Student[5];
        students[0] = new Student();

        ArrayList list = new ArrayList();
        Hashtable hashtable = new Hashtable();
        list.AddRange(arr6);
        list.Add(9);
        list.Add("abc");
        Console.WriteLine();
        foreach (object o in list)
        {
            Console.Write(o+"\t");
        }
        list.Remove(66);
        list.RemoveAt(2);
        list.RemoveRange(2,2);
        Console.WriteLine();
        foreach (object o in list)
        {
            Console.Write(o + "\t");
        }
        
        hashtable.Add("1", "111");
        hashtable.Add("2", "222");
        hashtable.Add("3", "333");
        Console.WriteLine(hashtable["1"]);
        foreach (DictionaryEntry entry in hashtable)
        {
            Console.WriteLine(entry.Key+"----"+entry.Value);
        }
        hashtable.Remove("2");
        


    }
    */
    
    //冒泡排序
    public void Sort(double[]a)
    {
        double  temp;
        for (int i = 0; i < a.Length-1; i++)
        {
            for(int j=0;j<a.Length -i-1;j++)
            {
                if(a[j]<a[j+1])
                {
                    temp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = temp;
                }
                    
            }
        }
    }

}